#-------------------------------------------------------------------------------
# Key mappings
#-------------------------------------------------------------------------------

# Replace main key binding 'ctrl-b' with 'ctrl-w'
#unbind C-b
unbind l
#set -g prefix C-w

# Set key binding + 'w' to switch to the last window used
#bind-key C-w last-window

# source tmux
bind-key r source-file ~/.tmux.conf

# moving/rearranging windows
bind-key m command-prompt -p "move window to:"  "swap-window -t '%%'"
#-------------------------------------------------------------------------------
# Terminal colors

# Set to use 256 colors
set -g default-terminal "screen-256color"
#setw -g utf8 on
#set -g status-utf8 on

#-------------------------------------------------------------------------------
# Theme

# Set status bar background color to colour232/black
set -g status-bg colour232

# Set windows backgrounded in the status bar to colour246/gray
set -g status-fg colour246

# Status bar refresh rate (seconds)
set -g status-interval 1

# Status bar character length
set -g status-left-length 30

# Sets current selected window to colour208/orange
set-window-option -g window-status-current-style fg=colour208

# Sets mode keys to use vim settings (for ? and / search in buffer scrolls)
set-window-option -g mode-keys vi

# On the left-side of status in green: print '{session_name} {user}@{hostname}'
set -g status-left '(#[fg=green](#S) #(whoami)@#H#[default]) '

# On the right of status in colour228/pastel_yellow : print time 'H:M m.d.y'
set -g status-right '#[fg=colour228]Pane: #P #(date)'
#
# Set pane colors (Terminal must be using utf-8)
set -g pane-border-style bg=green
set -g pane-border-style fg=white
set -g pane-active-border-style bg=yellow
set -g pane-active-border-style fg=green

# Note: To view all colors enabled
# for i in {0..255} ; do printf "\x1b[38;5;${i}mcolour${i}\n"; done

#-------------------------------------------------------------------------------
# Mouse controls

# Enable mouse
#set -g mode-mouse on

# Mouse can be used to select panes
#set-option -g mouse-select-pane on

# mouse can be used to select windows (by clicking in the status bar)
#set-option -g mouse-select-window on

# mouse can be used to resize panes (by dragging dividers)
#set-option -g mouse-resize-pane on

# new mouse mode for v2.1
set -g mouse on

# Start copy mode when scrolling up and exit when scrolling down to bottom.
# The "#{mouse_any_flag}" check just sends scrolls to any program running that
# has mouse support (like vim).
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"

#-------------------------------------------------------------------------------
# Misc

# Set history line limit
set -g history-limit 99999

# Fix the problem where tmux prints "1;2c"
set -sg escape-time 1

# Allows for faster key repetition
#set -s escape-time 0

# Disable window renaming (e.g. when SSH'ing)
set-option -g allow-rename off

bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
#-------------------------------------------------------------------------------

set-option -g pane-active-border bg=default
set-option -g pane-active-border fg=colour208
